
package br.com.agenda.server.servidor;

import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

import br.com.agenda.negocio.entity.IAgenda;


public class ServidorMain extends UnicastRemoteObject {

	private static final long serialVersionUID = -5665677127390083702L;
	private static final String URI = "rmi://localhost:12345/servidor";
	private ArrayList<IAgenda> agendas = new ArrayList<IAgenda>();
	
	public ServidorMain() throws RemoteException {}
	

	public static void main(String[] args) {

		try {	
			
			IServicoServidor servico = new ServicoServidor();
			LocateRegistry.createRegistry(12345);
            Naming.bind(URI, servico);
            System.out.println("Server started and up!");
        } 
		
        catch (AlreadyBoundException ex) {
            Logger.getLogger(ServidorMain.class.getName()).log(Level.SEVERE, null, ex);
        } 
        catch (MalformedURLException ex) {
            Logger.getLogger(ServidorMain.class.getName()).log(Level.SEVERE, null, ex);
        } 
        catch (RemoteException ex) {
            Logger.getLogger(ServidorMain.class.getName()).log(Level.SEVERE, null, ex);
        }

	}

}

